<?php
/*
function validate_email($email) {
	if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
	  return true;
	}
	return false;
}
*/

function createInsertQueryFromAssocArray($array, $table){
	$query = "INSERT INTO ".$table." (";
	$keys = array_keys($array);
	for ($i = 0; $i < count($keys) -1; $i++){
	   $query.=($keys[$i]).", ";
	}
	$query.=($keys[count($keys)-1]).") VALUES (";

	for ($i = 0; $i < count($keys) -1; $i++){
	   $query.="'".addslashes($array[$keys[$i]])."', ";
	}
	$query.="'".addslashes($array[$keys[count($keys)-1]])."')";
	return $query;
}

function createUpdateQueryFromAssocArray($array, $table, $where){
	$query = "UPDATE ".$table." SET ";
	$keys = array_keys($array);
	foreach($array AS $key => $value) {
		$query .= $key."='".addslashes($value)."',";
	}
	
	$query = substr($query,0,strlen($query)-1);
	$query .= " WHERE ".$where.";";
	return $query;
}
?>